import java.util.*;
public class Main{
    static int N = 100010;
    static Node L, R;
    static int index = 0;
    static Map<Integer, Node> map = new HashMap();
    static {
        L = new Node(-1);
        R = new Node(-1);
        L.right = R;
        R.left = L;
    }
    static void insert(Node p, Node t){
        t.right = p.right;
        p.right.left = t;
        t.left = p;
        p.right = t;
    }
    static void remove(Node p){
        p.left.right = p.right;
        p.right.left = p.left;
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        while(T -- > 0){
            String op = sc.next();
            if(op.equals("L")){
                Node p = new Node(sc.nextInt());
                insert(L, p);
                map.put(++ index, p);
            }else if(op.equals("R")){
                Node p = new Node(sc.nextInt());
                insert(R.left, p);
                map.put(++ index, p);
            }else if(op.equals("D")){
                int k = sc.nextInt();
                Node p = map.get(k);
                remove(p);
                map.remove(k);
            }else if(op.equals("IL")){
                int k = sc.nextInt();
                Node t = new Node(sc.nextInt());
                Node p = map.get(k);
                insert(p.left, t);
                 map.put(++index, t);
            }else{
                int k = sc.nextInt();
                Node t = new Node(sc.nextInt());
                Node p = map.get(k);
                insert(p, t);
                map.put(++index, t);
            }
        }
        for(var p = L.right; p != R; p = p.right ){
            System.out.print(p.val + " ");
        }
    }
    
    static class Node{
        int val;
        Node left, right;
        Node(int v){val = v;}
    }
}